package com.ky.gp.app.controller;

import com.ky.common.param.AddressAdd;
import com.ky.common.vo.R;
import com.ky.gp.app.service.AddressFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * --- 天道酬勤 ---
 *
 * @author 1379
 * @date 2024/6/18
 * @desc -- 代码敲烂 月薪过万--
 */
@RestController
@RequestMapping("/api/address")
public class AddressController {

    @Autowired
    private AddressFeign addressFeign;

    /**
     * 获取用户的地址
     * @param request
     * @return
     */
    @RequestMapping("/getAddressByUserId")
    public R getAddressList(HttpServletRequest request){

        return addressFeign.getAddressList();
    }

    /**
     * 添加地址
     * @param addAddress
     * @return
     */
    @RequestMapping("/addAddAddress")
    public R addAddress(@RequestBody AddressAdd addAddress){

        return  addressFeign.addAddress(addAddress);
    }

    /**
     * 更新地址
     * @param addressAdd
     * @return
     */
    @RequestMapping("/updateAddress")
    public R updateAddress(@RequestBody AddressAdd addressAdd){
        return addressFeign.updateAddress(addressAdd);
    }

    /**
     * 删除用户的地址
     * @param addressAdd
     * @return
     */
    @RequestMapping("/deleteAddress")
    public R deleteAddress(@RequestBody AddressAdd addressAdd){
        return addressFeign.deleteAddress(addressAdd);
    }

    /**
     * 根据地址id获取地址
     * @param id
     * @return
     */
    @RequestMapping("/getAddressByAddressId")
    public R getAddressByAddressId(@RequestParam("id")  String id){
        return addressFeign.getAddressByAddressId(id);
    }

    @RequestMapping("/getDefaultAddress")
    public R getdefaultAddress(){
        return addressFeign.getdefaultAddress();
    }
}
